package de.dubiel.plung.client.play;

import com.google.gwt.canvas.dom.client.Context2d;

import de.dubiel.plung.client.canvas.Rectangle;
import de.dubiel.plung.client.canvas.Vector;

public class Paddle extends Rectangle {
    private Vector drawingCorners;
    private Vector position;

    public Paddle(int width, int height) {
        drawingCorners = new Vector(width / 2, height / 2);
        this.setWidth(width);
        this.setHeight(height);
    }

    public void setPosition(Vector pos) {
        this.position = pos;
    }

    public Vector getPosition() {
        return position;
    }

    @Override
    public void draw(Context2d context) {
        this.setTopLeft(Vector.sub(this.position, this.drawingCorners));
        super.draw(context);
    }
}
